<?php

$pluginName = 'exif';
class metadataPlugins_exif extends BaseMetadata
{
	public function saveMeta()
	{
		$exif = @exif_read_data($this->file->getURI());
		$type = $this->file->getType();

		$keyList = array('Make', 'Model', 'DateTime');
		if(isset($exif['Make']))
		{
			$this->addMetadata($exif['Make'], $type);
		}
		
		if(isset($exif['Model']))
		{
			$this->addMetadata($exif['Model'], $type);
		}
		
		if(isset($exif['DateTime']))
		{
			$date = JGLib::trDate($exif['DateTime']);
			$this->addMetadata($date['d'].'/'.$date['m'].'/'.$date['y'], $type);
		}
		
		return parent::saveMeta();
	}
	
	public function maxMeta($str)
	{
		if(!INCLUDE_EXTENTION_IN_METADATA)
		{
			$t = explode('.', $str);
			array_pop($t);
			$str = implode('.',$t);
		}
		return split('[^A-Za-z0-9]', $str);
	}
	
	public function getDirectories($str)
	{
		return explode(OS_PATH_SEPARATOR, $str);
	}
	
	public function unCamelize($str)
	{
		return JGLib::unCamelize($str);
	}
	
	public static function getPluginName()
	{
		return 'exif';
	}
	
	public static function getPluginDescription()
	{
		return 'metadata based on exifs tags from camera on jpg files';
	}
	
	public static function getMimeHandle()
	{
		return array(
			'image/jpeg',
			'image/tiff');
	}
	
}
